package day20171010;

public abstract class Shape {
    public int x,y;
    public  int width,height;
    public Shape(int x1,int y1,int width1,int height1){
        x=x1;
        y=y1;
        width=width1;
        height=height1;
    }
    abstract double getArea();
    abstract  double getPerimeter();
}
class Square extends Shape{

    public Square(int x1, int y1, int width1, int height1) {
        super(x1, y1, width1, height1);
    }

    @Override
    double getArea() {
        return width*height;
    }

    @Override
    double getPerimeter() {
        return (2*width+2*height);
    }
}
class Circle extends Shape{

    public Circle(int x1, int y1, int width1, int height1) {
        super(x1, y1, width1, height1);
        r=(double)width/2.0;
    }
    public double r;
    @Override
    double getArea() {
        return Math.PI*r*r;
    }

    @Override
    double getPerimeter() {
        return Math.PI*2*r;
    }
}
class Text{
    public static void main(String[] args) {
        Square box=new Square(5,15,20,2);
        Circle ovar=new Circle(5,50,20,20);
        System.out.println("box area="+box.getArea());
        System.out.println("box perimeter="+box.getPerimeter());
        System.out.println("ovar area="+ovar.getArea());
        System.out.println("ovar perimeter="+ovar.getPerimeter());
    }

        }